package com.wyp168.jse;

/**
 * @ClassName StringBufferAndStringBuilderDemo001
 * @Description TODO
 * @Author wyp168
 * @Date 2022/8/8 09:16
 */
public class StringBufferAndStringBuilderDemo001 {
    private static StringBuffer sb = new StringBuffer();

    public static void main(String[] args) {
        Thread threadA =  new Thread(() -> {
            String subStr = "";
            for (int i = 2; i < 100; i += 10) {
                subStr = subStr + i + ",";
            }
            sb.append(subStr);
        });

        Thread threadB =  new Thread(() -> {
            String a = "";
            for (int j = 1; j < 100; j += 10) {
                a = a + j + ",";
            }
            sb.append(a);
        });

        try {
            threadA.start();
            threadB.start();

            threadA.join();
            threadB.join();
            System.out.println(sb);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
